package router

import (
	"quick-go/controller"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()

	// r.GET("/ping", func(c *gin.Context) {
	// 	c.JSON(200, gin.H{
	// 		"message": "pong",
	// 	})
	// })

	user := r.Group("/user")
	{
		// user.GET("/id", func(c *gin.Context) {
		// 	c.JSON(200, gin.H{"message": "id"})
		// 	c.String(http.StatusOK, "user id")
		// })
		user.GET("/id/:id", controller.UserController{}.GetUserOne) // :id 为参数，拼接在 /id/ 后面
		user.GET("/list", controller.UserController{}.GetUserList)

		user.POST("/create", controller.UserController{}.CreateUser)
		user.PUT("/update", controller.UserController{}.UpdateUser)
		user.DELETE("/delete", controller.UserController{}.DeleteUser)

		user.GET("/test/lt3", controller.UserController{}.GetUserLT3)
	}

	order := r.Group("/order")
	{
		order.GET("/id", controller.OrderController{}.GetOrderOne)
	}

	return r
}
